package Loganseabolt.tools;

import java.util.List;
import java.util.Random;

import Loganseabolt.LoganSeaboltModBase;

import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntitySnowball;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraft.world.gen.structure.ComponentVillageStartPiece;
import net.minecraft.world.gen.structure.ComponentVillageWoodHut;
import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureComponent;

public class wand_o_Dia extends ItemSword {

        

        public wand_o_Dia(int par1, EnumToolMaterial par2EnumToolMaterial) {
		super(par1, par2EnumToolMaterial);
		this.setCreativeTab(CreativeTabs.tabMisc);
		// TODO Auto-generated constructor stub
	}

		public void registerIcons(IconRegister iconReg) {
                itemIcon = iconReg.registerIcon("LoganSeaboltModBase:TROLLO");
        }

        public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,EntityPlayer par3EntityPlayer) 
        {
                if (!par2World.isRemote)
                {
                        par3EntityPlayer.posY++;
                        //MovingObjectPosition coord = par3EntityPlayer.rayTrace(2, 1);
                        Vec3 vec = par3EntityPlayer.getPosition(1).addVector(0, -15, 0);
                        
                        if (vec != null)
                        {
                                
                                int height = 15;
                                int length = 5;
                                int depth = 5;
                                vec.xCoord-= length/2;
                                vec.zCoord -= depth/2;
                                //int number = 0;
                                
                                /*do{
                                        par2World.setBlockToAir((int)vec.xCoord, (int)vec.yCoord++,(int) vec.zCoord + number);
                                        par2World.setBlockToAir((int)vec.xCoord+ number, (int)vec.yCoord++,(int) vec.zCoord);
                                        number = number + 1;
                                }
                                while (number < 10);*/
                                for (int i = 0; i < length;i++)
                                {
                                	for (int j = 0; j < depth;j++)
                                    {
                                		for (int k = 0; k < height;k++)
                                        {
                                			par2World.setBlock((int)vec.xCoord+j, (int)vec.yCoord+k,(int) vec.zCoord+i, 0);
                                        }
                                    }
                                }
                                for (int j = 0; j < length; j ++)
                                {
                                        for (int k = 0; k < depth; k ++)
                                        {
                                                par2World.setBlock((int)vec.xCoord+j, (int)vec.yCoord,(int) vec.zCoord+k, Block.bedrock.blockID);
                                        }
                                        
                                }
                                vec.yCoord++;
                                for (int i = 0;i < height;i++)
                                {
                                	
                                           
                                        for (int j = 0; j < length-1; j ++)
                                        {
                                                par2World.setBlock((int)vec.xCoord++, (int)vec.yCoord,(int) vec.zCoord, Block.obsidian.blockID);
                                                
                                        }
                                        for (int k = 0; k < depth-1; k ++)
                                        {
                                                par2World.setBlock((int)vec.xCoord, (int)vec.yCoord,(int) vec.zCoord++, Block.obsidian.blockID);
                                                
                                        }
                                        for (int l = 0; l < length-1; l ++)
                                        {
                                                par2World.setBlock((int)vec.xCoord--, (int)vec.yCoord,(int) vec.zCoord, Block.obsidian.blockID);
                                                
                                        }
                                        for (int m = 0; m< depth-1; m ++)
                                        {
                                                par2World.setBlock((int)vec.xCoord, (int)vec.yCoord,(int) vec.zCoord--, Block.obsidian.blockID);
                                                
                                        }
                                     
                                        vec.yCoord++;
                                }
                                vec.yCoord--;
                                for (int j = 0; j < length; j ++)
                                {
                                        for (int k = 0; k < depth; k ++)
                                        {
                                        	    	par2World.setBlock((int)vec.xCoord+j, (int)vec.yCoord,(int) vec.zCoord+k, LoganSeaboltModBase.Dia.blockID);
                                        }
                                      
                                }
                                
                                
                        }
                        
                        
                        par3EntityPlayer.posY--;
                }
                par1ItemStack.stackSize--;
                return par1ItemStack;
        }
}

